✨ Add applications and project members functionality with schema updates#68
✨ Add applications and project members functionality with schema updates#68
Conversation
… for ceo_id, is_opensource, and is_dead
There was a problem hiding this comment.
Pull Request Overview
This PR implements application and project member functionality by extending the database schema, models, service logic, routes, and schemas to support apply/approve workflows and adds new project attributes.
- Adds
ApplicationandProjectMembermodels, migrations, and data-access methods for project applications and members - Extends
ProjectService, routes, and Pydantic schemas to handle apply, list, and approve operations - Updates database dependency to centralize commits and refines user ID typing in auth services
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/app/models/applications.py | New Application model for user-project applications |
| backend/app/models/project_member.py | New ProjectMember model for approved project members |
| backend/app/models/projects.py | Added ceo_id, is_opensource, is_dead, and __repr__ |
| backend/app/models/users.py | Made role column nullable |
| backend/app/routes/api/project/schemas.py | Extended project, application, and member schemas |
| backend/app/routes/api/project/data_access.py | Added data-access logic and custom exception for applications |
| backend/app/routes/api/project/service.py | Service methods for apply, list, and approve workflows |
| backend/app/routes/api/project/router.py | New routes for project application endpoints |
| backend/app/dependencies/database.py | Moved commit into DB dependency |
| backend/app/services/auth.py | Updated get_user_by_username return type |
| backend/app/schemas/user.py | Added optional id field to UserInDB |
Comments suppressed due to low confidence (2)
backend/app/routes/api/project/schemas.py:38
- [nitpick]
ProjectMemberSchemaomitscreated_ateven though the model records it. Addcreated_at: datetime(ordate) to the schema for consistency.
class ProjectMemberSchema(BaseModel):
backend/app/models/users.py:22
- [nitpick] The
rolecolumn was made nullable, potentially allowing users without a role. For data integrity, consider keeping it non-nullable or adding a default.
nullable=True,
| status_code=403, | ||
| detail="You cannot approve your own application.", | ||
| ) | ||
| await self.data_access.approve_application( |
There was a problem hiding this comment.
The approve_application call in service can raise ProjectNotFoundError and is not caught, resulting in a 500. Catch this exception and convert to an HTTPException with a 404 status.
| is_dead: bool | ||
|
|
||
|
|
||
| class ProjectSchema(NewProjectSchema): |
There was a problem hiding this comment.
Tests reference a status field on ProjectSchema (e.g., status="active"), but ProjectSchema does not define status. Add status: str to the schema.
|
|
||
|
|
||
| class ProjectsDataClass: | ||
| class ProjectNotFoundError(Exception): |
There was a problem hiding this comment.
[nitpick] The exception ProjectNotFoundError is used for missing application records. Consider renaming it to ApplicationNotFoundError for clarity.
| class ProjectNotFoundError(Exception): | |
| class ApplicationNotFoundError(Exception): |
backend/app/models/applications.py
Outdated
|
|
||
| project_id = Column(Integer, ForeignKey("projects.id")) | ||
| user_id = Column(Integer, ForeignKey("users.id")) | ||
| created_at = Column(Date, default=func.current_date()) |
There was a problem hiding this comment.
ApplicationSchema.created_at is typed as datetime but the model uses SQL Date. Either change the column to DateTime or update the schema to date.
| created_at = Column(Date, default=func.current_date()) | |
| created_at = Column(DateTime, default=func.current_timestamp()) |
| except Exception as e: | ||
| await session.rollback() | ||
| raise e | ||
| await session.commit() |
There was a problem hiding this comment.
[nitpick] Committing in the DB dependency will commit after all operations, including GET requests. Consider committing only in write operations or in service methods.
| await session.commit() |
…to a separate file
…ers, and projects
Closes #64
Closes #65
Closes #66